package org.hs.phd.odi.tracking.tracker;

import java.awt.Color;
import java.awt.Polygon;
import java.util.ArrayList;
import java.util.List;

import com.googlecode.javacv.cpp.opencv_core.IplImage;

public class TrackerGroup {

	
	private List<Tracker> trackers;
	private List<Track> tracks;
	private boolean isInitialized;
	
	public TrackerGroup(){
		trackers = new ArrayList<Tracker>();
		tracks = new ArrayList<Track>();
		isInitialized = false;
	}

	public void add(Tracker tracker, Color color) {
		trackers.add( tracker);
		tracks.add(new Track(color, null));
	}

	public void initTrackers( Polygon initialTrackShape, IplImage initialFrame) {
		for(int i = 0; i < trackers.size(); i++){
			tracks.get(i).setTrackWindow( trackers.get(i).init(initialTrackShape, initialFrame) );
		}
		isInitialized = true;
	}

	public void dropTracks() {
		// TODO Auto-generated method stub
		
	}

	public void updateWithNextFrame(IplImage frame) {
		
		if( !isInitialized) return;
		
		for(int i = 0; i < trackers.size(); i++){
			tracks.get(i).setTrackWindow( trackers.get(i).track(frame) );
		}
	}

	public List<Track> getTracks() {
		return tracks;
	}

}
